local qingxinlengyi = fk.CreateSkill{
    name = "rmt__qingxinlengyi",
    tags = {Skill.Compulsory},
}
Fk:loadTranslationTable{
    ["rmt__qingxinlengyi"] = "清心冷意",
    [":rmt__qingxinlengyi"] = "锁定技，当你使用的牌被抵消，或你受到的伤害被防止后，你将手牌数和体力值中更少的一项向另一项调整1，若无事发生，则你重铸所有手牌。",
}

local spec = {
    on_use = function (self, event, target, player, data)
        local room = player.room
        if player.hp > player:getHandcardNum() then
            player:drawCards(1,qingxinlengyi.name)
        elseif player:getHandcardNum() > player.hp and player:isWounded() then
            room:recover({
                who = player,
                num = 1,
                recoverBy = player,
                skillName = qingxinlengyi.name,
            })
        else
            room:recastCard(player:getCardIds("h"),player,qingxinlengyi.name)
        end
    end,
}

qingxinlengyi:addEffect(fk.CardEffectCancelledOut, {
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(qingxinlengyi.name) then
            return data.from and data.from == player
        end
    end,
    on_use = spec.on_use,
})

qingxinlengyi:addEffect(fk.DamageFinished, {
    can_trigger = function(self, event, target, player, data)
        if player:hasSkill(qingxinlengyi.name) then
            return not data.dealtRecorderId and data.to == player
        end
    end,
    on_use = spec.on_use,
})

return qingxinlengyi